
Free Online JSON Formatter and Validator
Paste JSON to format, minify or validate it, see the exact line and column of any error and browse the result as a tree.
JSON is the plain-text format that most websites, apps and APIs use to pass data around. It is easy for machines to read and, when it is neatly laid out, fairly easy for people too. Unfortunately a single missing comma can break a whole file. This tool formats JSON so you can read it, minifies it so it is small and, most importantly, tells you the exact line and column where it is broken.
What JSON looks like
JSON stands for JavaScript Object Notation. It has only a few building blocks: objects in curly braces, arrays in square brackets, strings in double quotes, numbers, true, false and null.
{"name": "Sam", "tools": ["pen", "ruler"], "age": 12, "active": true}
An object is a set of “key”: value pairs. An array is an ordered list. Values can nest inside each other as deep as needed, which is why long JSON is hard to read until it is indented.
How to use the tool
- Paste your JSON into the Input box, or open a .json file.
- Press Format to indent it, Minify to remove all extra spaces or Validate only to check it without changing the output.
- If it is valid, you see a green message and the statistics. If not, a red message names the line and column and the box highlights the spot.
- Switch to Tree view to open and close branches.
- Copy the result or download it as a file.
The errors you will meet most
| Problem | Bad | Fix |
|---|---|---|
| Trailing comma | {“a”: 1,} | Remove the last comma |
| Single quotes | {‘a’: 1} | Use double quotes |
| Unquoted key | {a: 1} | Write “a” |
| Comment | // note | JSON has no comments |
| Leading zero | {“n”: 007} | Write 7, or use a string |
| Special value | NaN, undefined | Use null or a string |
Many of these are legal in JavaScript but not in strict JSON, which is why code that works in a script may fail when you paste it here.
How the error position is found
This tool reads the text with its own strict parser rather than relying on the browser’s error message, because browsers phrase errors in different ways and some give only a character offset. The parser follows the official rules one character at a time. When it hits something illegal it stops and counts how many line breaks and characters came before, giving a line and column you can jump straight to. It also shows the broken line with a caret under the problem.
Try it with {"a":1, on the first line and a second line that reads a space, then "b":2,}. The tool reports the problem on line 2, column 8: a trailing comma before the closing brace.
Big numbers keep their digits
JavaScript stores numbers as 64-bit floating point values, so an integer with more than about 15 or 16 digits can be rounded silently. If you paste 12345678901234567890 into a typical script and print it, you may get a different number. This formatter keeps number text exactly as you typed it, so formatting never changes your data. It adds a reminder when it spots very long numbers, because the program that later reads the file might still round them.
Safe handling of your data
JSON from unknown sources can be hostile. This tool never runs your text as code. It does not use eval. Keys such as “__proto__” are treated as ordinary text, so they cannot change how the page behaves. Nesting deeper than 200 levels is refused to avoid crashes, input is limited to 10 MB and the tree view limits very long lists. Everything stays in your browser.
What it is good for
- Reading the answer of a web API while you build an app.
- Cleaning a configuration file before you commit it.
- Checking that data from a spreadsheet export is valid.
- Sorting keys alphabetically so two files can be compared.
- Minifying JSON to save space before sending it.
A worked example
The sample button loads a small object with a nested list, a null, a decimal written as 1.10 and a 20-digit number. Press Format and you see the structure indented by two spaces. The statistics list keys, objects, arrays, depth, strings and numbers. Press Minify and the same data collapses to one line. The number 1.10 stays exactly 1.10, because formatting does not change values.
Common mistakes
- Copying text from a web page that uses curly “smart” quotes.
- Leaving out a comma between items after editing by hand.
- Pasting two JSON objects one after another. A file must hold one value.
- Mixing up JSON with JavaScript objects.
- Fixing only the first error and not testing again.
If you are learning to work with data, take the JavaScript course and the API integration skill. The regex tester helps you search inside text and the Base64 tool decodes encoded data. For simple data habits, see 15 essential digital skills.
Key takeaways
- JSON needs double quotes, no trailing commas and no comments.
- The error message shows line and column so you can fix it quickly.
- Formatting never changes your values, even long numbers.
- Your data is processed locally and never executed.
Questions
What is the difference between formatting and minifying JSON?
Formatting adds line breaks and indentation so people can read it. Minifying removes every unnecessary space and line break so the file is as small as possible. Both keep exactly the same data, and you can switch between them at any time without losing anything.
How does the tool show where my JSON is broken?
It reads the text with a strict parser and stops at the first problem. It then reports the line and column, explains what was expected and shows the broken line with a marker under the problem. The input box also selects that character so you can fix it quickly.
Why is my JSON invalid when it works in JavaScript?
JavaScript allows things that strict JSON forbids, such as single quotes, unquoted keys, trailing commas, comments and values like undefined or NaN. JSON is stricter so that every program can read it the same way. Change those items to the strict forms listed on this page.
Is my data sent to a server?
No. The text is processed in your browser and is never uploaded or stored. It is parsed as data and never run as code, so even unusual or hostile-looking input cannot execute anything. Large files up to 10 megabytes are accepted, and deep nesting is limited for safety.
Will it change my numbers or key order?
No numbers are changed. The tool keeps number text exactly as written, so long integers and values such as 1.10 stay the same. Key order also stays the same unless you tick Sort keys A to Z, which you can use to make two files easier to compare.
